package com.ruoyi.web.controller.pollution;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.pollution.domain.BusPsCodPollutant;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pollution.domain.BusPsCodPollutant;
import com.ruoyi.pollution.service.IBusPsCodPollutantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 污染物信息Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/buspollutant")
public class BusPsCodPollutantController extends BaseController
{
    @Autowired
    private IBusPsCodPollutantService busPsCodPollutantService;

    /**
     * 查询污染物信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusPsCodPollutant busPsCodPollutant)
    {
        startPage();
        List<BusPsCodPollutant> list = busPsCodPollutantService.selectBusPsCodPollutantList(busPsCodPollutant);
        return getDataTable(list);
    }

    @GetMapping("/listall")
    public AjaxResult listall(BusPsCodPollutant busPsCodPollutant)
    {
        List<BusPsCodPollutant> list = busPsCodPollutantService.selectBusPsCodPollutantList(busPsCodPollutant);
        return AjaxResult.success(list);
    }

    /**
     * 导出污染物信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:export')")
//    @Log(title = "污染物信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusPsCodPollutant busPsCodPollutant)
    {
        List<BusPsCodPollutant> list = busPsCodPollutantService.selectBusPsCodPollutantList(busPsCodPollutant);
        ExcelUtil<BusPsCodPollutant> util = new ExcelUtil<BusPsCodPollutant>(BusPsCodPollutant.class);
        util.exportExcel(response, list, "污染物信息数据");
    }

    /**
     * 获取污染物信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:query')")
    @GetMapping(value = "/{pollutantcode}")
    public AjaxResult getInfo(@PathVariable("pollutantcode") String pollutantcode)
    {
        return success(busPsCodPollutantService.selectBusPsCodPollutantByPollutantcode(pollutantcode));
    }

    /**
     * 新增污染物信息
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:add')")
//    @Log(title = "污染物信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusPsCodPollutant busPsCodPollutant)
    {
        return toAjax(busPsCodPollutantService.insertBusPsCodPollutant(busPsCodPollutant));
    }

    /**
     * 修改污染物信息
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:edit')")
//    @Log(title = "污染物信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusPsCodPollutant busPsCodPollutant)
    {
        return toAjax(busPsCodPollutantService.updateBusPsCodPollutant(busPsCodPollutant));
    }

    /**
     * 删除污染物信息
     */
//    @PreAuthorize("@ss.hasPermi('system:POLLUTANT:remove')")
//    @Log(title = "污染物信息", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busPsCodPollutantService.deleteBusPsCodPollutantByPollutantcodes(ids));
    }
}
